
pkgname=kmod
pkgver=25
pkgrel=1
#_kver=4.0.5-1
pkgdesc="Linux kernel module handling"
arch=('x86_64')
url='https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/tree/README'
license=('GPL2')
depends=('glibc' 'zlib')
options=('!libtool')
source=("https://www.kernel.org/pub/linux/utils/kernel/kmod/${pkgname}-${pkgver}.tar.xz"
        'depmod-search.conf')
md5sums=('34f325cab568f842fdde4f8b2182f220'
         '9ae9acc68ca27134f55a0959073b8e53')

build() {
  cd ${pkgname}-${pkgver}

  ./configure \
    --sysconfdir=/etc \
    --with-zlib \
    --disable-test-modules
  make
}

check() {
  make -C ${pkgname}-${pkgver} check 
}

package() {
  make -C${pkgname}-${pkgver} DESTDIR=${pkgdir} install

  # extra directories
  install -dm755 ${pkgdir}/{etc,usr/lib}/{depmod,modprobe}.d ${pkgdir}/sbin
  
  # add symlinks to kmod
  ln -s ../usr/bin/kmod ${pkgdir}/sbin/modprobe
  ln -s ../usr/bin/kmod ${pkgdir}/sbin/depmod

  for tool in {ins,ls,rm,dep}mod mod{probe,info}; do
    ln -s kmod ${pkgdir}/usr/bin/$tool
  done

  # install depmod.d file for search/ dir
  install -Dm644 ${srcdir}/depmod-search.conf ${pkgdir}/usr/lib/depmod.d/search.conf
}
